<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="root">
    <Fx></Fx>
    <Fx2></Fx2>
  </div>


  <script type="text/x-template" id="fx">
  <div>
    <h3>{{ username }}</h3>
  </div>
  </script>

  <script type="text/x-template" id="fx2">
    <div>
      <h3>fx2</h3>
      <Child></Child>
    </div>
    </script>
  <script src="./js/vue.js"></script>
  <script>

    // 定义局部组件的对象
    const Fx = {
      template: '#fx',
      data() {
        return {
          username: '张三'
        }
      }
    }

    const Child = {
      template: '<div>我是child</div>'
    }

    const Fx2 = {
      template: '#fx2',
      components: { Child }
    }

  

    new Vue({
      el: '#root',
      // 局部组件
      components: {
        Fx,
        Fx2
      }
    })
  </script>
</body>

</html>